package com.zuul.config

import org.springframework.context.annotation.Primary
import org.springframework.stereotype.Component
import springfox.documentation.swagger.web.SwaggerResource
import springfox.documentation.swagger.web.SwaggerResourcesProvider

//http://localhost:81/swagger-ui.html
//http://localhost:81/docs.html,http://localhost:81/zuul_???/docs.html

@Component
@Primary
class SwaggerConfig : SwaggerResourcesProvider {
    override fun get(): MutableList<SwaggerResource> {
        return arrayListOf(
                swaggerRes("ApiDoc", "/zuul_api/v2/api-docs"),
                swaggerRes("Service1Doc", "/zuul_service1/v2/api-docs"),
                swaggerRes("Service2Doc", "/zuul_service2/v2/api-docs"),
                swaggerRes("SocketDoc", "/zuul_socket/v2/api-docs")
        )
    }

    fun swaggerRes(name: String, location: String): SwaggerResource {
        val res = SwaggerResource()
        res.name = name
        res.location = location
        res.swaggerVersion = "2.0"
        return res
    }
}
